<?php

use yii\db\Migration;

class m210222_082922_addon_car extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%addon_car}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID'",
            'cate_id' => "int(11) NOT NULL DEFAULT '0' COMMENT '车型'",
            'merchant_id' => "int(11) NOT NULL",
            'title' => "varchar(32) NOT NULL COMMENT '名称'",
            'plate_number' => "varchar(32) NOT NULL COMMENT '车牌号'",
            'vehicle_license' => "varchar(32) NOT NULL COMMENT '行驶证'",
            'insurance' => "date NULL COMMENT '保险'",
            'inspection' => "date NULL COMMENT '年检'",
            'mileage' => "int(11) NULL DEFAULT '0' COMMENT '里程'",
            'mark' => "varchar(255) NULL COMMENT '备注'",
            'state' => "int(11) NULL DEFAULT '0' COMMENT '0空闲1使用中'",
            'picture' => "varchar(255) NULL",
            'covers' => "text NULL",
            'status' => "tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态'",
            'created_at' => "int(10) NOT NULL COMMENT '创建时间'",
            'updated_at' => "int(10) NOT NULL COMMENT '更新时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%addon_car}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

